package com.dlq.logistical.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dlq.logistical.util.DateUtils;
import com.dlq.logistical.util.ParamUtil;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

/**
 * 日志记录
 * @author Administrator
 *
 */
public class LogController  extends BaseController {
   public static final String  TABLE="t_http_log";
   public static final String  PRIMARY="id";
   
   public void saveLog(String userId,String url,String client_information){
	   Map<String, Object> data=new HashMap<String, Object>();
	   data.put("user_id", userId);
	   data.put("url", url);
	   data.put("client_information", client_information);
	   data.put("create_time", DateUtils.getCurrDateTimeStr());
	   saveOrUpdate(TABLE, PRIMARY, data);
   }
   
   public void index(){
	     Integer pageNumber = getParaToInt("pageNumber")==null?1:getParaToInt("pageNumber");
		 Integer pageSize =getParaToInt("pageSize")==null?10:getParaToInt("pageSize"); 
		 String userName = getPara("userName");
		 userName = ParamUtil.isEmpty(userName) ? "%%" : "%"+userName+"%" ; 
		 String sqlText=getSqlText("getLog");
		 Page<Record> rePage=querysSqlTextByPage(pageNumber,pageSize,sqlText,userName);
		 renderJson(rePage);
   }
}
